package org.peoples.tests.rooms;

import java.util.Date;

import junit.framework.TestCase;

import org.junit.Before;
import org.junit.Test;
import org.peoples.rooms.RoomProperties;

public class TestRoomProperties extends TestCase {
	
	RoomProperties properties;
	
	public TestRoomProperties(String name) {
		super(name);
	}
	
	@Before
	public void setUp() throws Exception {
		properties = new RoomProperties();
		properties.ID = 1;
		properties.name = "Room 1";
		properties.description = "Room 1 Description";
		properties.creationDate = new Date();
	}

	@Test
	public void testEqualsObject() {
		RoomProperties room2 = new RoomProperties();
		room2.ID = 2;
		room2.name = "Room 2";
		room2.description = "Room 2 Description";
		room2.creationDate = new Date();

		RoomProperties room3 = new RoomProperties();
		room3.ID = 1;
		room3.name = "Room 1";
		room3.description = "Room 3 Description";
		room3.creationDate = new Date();
		
		assertTrue("properties == properties", properties.equals(properties));
		assertFalse("properties == room2", properties.equals(room2));
		assertTrue("properties == room3", properties.equals(room3));
		
		assertEquals(properties, room3);
	}
	
	public void testHashCode() {
		RoomProperties room2 = new RoomProperties();
		room2.ID = 2;
		room2.name = "Room 2";
		room2.description = "Room 2 Description";
		room2.creationDate = new Date();
		
		RoomProperties room3 = new RoomProperties();
		room3.ID = 1;
		room3.name = "Room 1";
		room3.description = "Room 1 Description";
		room3.creationDate = new Date();

		RoomProperties room4 = new RoomProperties();
		room4.ID = 1;
		room4.name = "room 1";
		room4.description = "Room 1 Description";
		room4.creationDate = new Date();
		
		assertFalse(properties.hashCode() == room2.hashCode());
		assertEquals(properties.hashCode(), room3.hashCode());
		assertFalse(properties.hashCode() == room4.hashCode());
	}

}
